# -*- coding: utf-8 -*-
"""
Created on Mon Jul  1 09:00:11 2024

@author: YANCL
"""

# 腐蚀+膨胀

import cv2
import numpy as np

input_img = cv2.imread("photo\\ganraotu.bmp", cv2.IMREAD_UNCHANGED)
kernel = np.ones((5,5), np.uint8)       #使用的卷积核
erode_img = cv2.erode(input_img, kernel, iterations = 2)    #腐蚀 2次
dilate_img = cv2.dilate(erode_img, kernel, iterations = 3)  #膨胀 3次

cv2.imshow("Original", input_img)   #显示原始图像
cv2.imshow("fushi", erode_img)      #显示腐蚀图像
cv2.imshow("pengzhang", dilate_img) #显示膨胀图像

cv2.waitKey()
cv2.destroyAllWindows()

